#pragma once

#include <list>

#include "RegKey.h"
#include "RegKeyValue.h"
#include "RegFormat.h"

class RegManage
{
public:
	typedef std::list<RegKey> RegKeyArray;
	typedef RegKeyArray::iterator RegKeyArrayIter;
public:
	RegManage(void);
	~RegManage(void);
public:
	void Printf();
public:
	void SetRegRoot(HKEY root) { root_ = root; }
	void ReadReg(CString path, bool isIncludeSubKey=false);
	void WriteReg();

	void ReadIni(CString path);
	void WriteIni(CString path);

private:
	void ReadRegKey(CString path,bool isIncludeSubKey);
	void ReadRegValue(CString path);

	void WriteRegKey(const RegKey& regKey);
	void WriteRegKeyValue(HKEY hKey, const RegKeyValue& regKeyValue);

	void AddKey(CString path);
	void AddRegValue(CString name, DWORD type, const BYTE* data, size_t len);

private:
	RegKeyArray keyArray_;
	RegKeyArrayIter curIter_;
	HKEY root_;
};
